home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 014 / libtools.arc / NEWBELL.AQM / NEWBELL.ASM
Encoding:
Assembly Source File  |  1984-08-31  |  1.5 KB  |  67 lines

  1. ;NEWBELL 2-24-83 by Jim Keesey, 2945 Sandra Pl., Palo Alto, CA    94303
  2. ;    changes 2-25-83 by J. R. Celoni, S.J.
  3. ;    <CSL.JLH.Celoni@SU-SCORE.ARPA>
  4. ;Run after boot to change DOS (not Basic) bell tone and length.
  5.  
  6. note_length    equ    09a00h    ;length (ms) * 131.072
  7. note        equ    0a98h    ;2712 = 1193180. / 440Hz
  8.  
  9. cseg    segment public 'code'
  10.     assume    cs:cseg,ds:cseg
  11.     org    100h
  12. start    proc    far
  13.     jmp    initial
  14. start    endp
  15.  
  16.         even
  17. video_io    dd    0
  18.  
  19. new_bell    proc    near
  20.     sti            ;enable
  21.     cmp    ah,0eh        ;tty mode
  22.     jz    nb1        ;yes
  23. vid:    jmp    cs:video_io    ;goto rom
  24. nb1:    cmp    al,7        ;bell
  25.     jnz    vid        ;no, let rom do it
  26.  
  27. ;see IBM Tech. Ref. Man. p. A-18:  BEEP & ERR_BEEP
  28. ;
  29.     cli            ;MUST disable
  30.     mov    al,0b6h     ;sel tim 2,lsb,msb,binary
  31.     out    43h,al        ;set up timer chip
  32.     mov    ax,note     ;get note
  33.     out    42h,al        ;write timer 2 count:  lsb...
  34.     mov    al,ah
  35.     out    42h,al        ;...and msb
  36.     in    al,61h
  37.     mov    ah,al        ;save current port setting
  38.     or    al,3
  39.     out    61h,al        ;turn spkr on
  40.     mov    cx,note_length    ;64K = 500 ms
  41. here:    loop    here        ;delay
  42.     mov    al,ah
  43.     out    61h,al        ;restore port setting
  44.     sti            ;enable
  45.     iret
  46. new_bell    endp
  47.  
  48. initial proc    near
  49.     cli
  50.     xor    ax,ax
  51.     mov    ds,ax        ;address interrupts
  52.     mov    si,40h        ;int 10h:  video_io
  53.     lea    di,video_io
  54.     mov    cx,2
  55.     rep    movsw        ;save old trap loc
  56.     mov    si,40h        ;int 10h
  57.     lea    ax,new_bell
  58.     mov    word ptr [si],ax    ;store new trap loc...
  59.     mov    word ptr [si+2],cs    ;...& code seg
  60.     lea    dx,initial
  61.     inc    dx        ;one past last byte needed
  62.     int    27h        ;terminate & stay resident
  63. initial endp
  64.  
  65. cseg    ends
  66.     end    start
  67.